import Axios from 'axios'
import request from '@/utils/request'
import { transformQueryCondition } from '@/utils'
import qs from 'qs'
import _ from 'lodash'


// 插入
export function insertItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo',
    method: 'POST',
    data: data
  })
}

// 批量插入
export function batchInsertItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo/batch',
    method: 'POST',
    data: data
  })
}

// 复合检索
export function compositeSelect(query) {
  // query = JSON.parse(JSON.stringify(query))
  query = _.cloneDeep(query)
  if (query.condition.status.value === '') {
    query.condition.status.value = [0, 1]
  }
  const searchCon = transformQueryCondition(query)
  return request({
    url: `/uums/SysUserCompound/selectUsercompound?orgId=${query.orgId}`, //  url: '/uums/SysUserInfo/select',
    method: 'POST',
    data: searchCon
  })
}
// 求件
export function countSelect(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/OzOrgUserinfo/count',
    method: 'POST',
    data: searchCon
  })
}

// 强制删除
export function forceDeleteItem(data) {
  return request({
    url: '/uums/SysUserInfo',
    method: 'DELETE',
    data: data
  })
}

// 批量强制删除
export function batchDeleteItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo/force/batch',
    method: 'DELETE',
    data: data
  })
}

// 检索
export function select(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/OzOrgUserinfo/select',
    method: 'POST',
    data: searchCon
  })
}

// 更新
export function updateItem(data) {
  var searchCon = transformQueryCondition(data)
  searchCon.value = data.value
  return request({
    url: '/uums/SysUserInfo',
    method: 'PUT',
    data: searchCon
  })
}
// 更新密码
export function updatePassWord(data) {
  return request({
    url: '/uums/common/user/changePassword',
    method: 'POST',
    data: data
  })
}

// 检索
export function selectSysSubsys(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/SysSubsys/select',
    method: 'POST',
    data: searchCon
  })
}

// 检索
export function selectMenuTree(id) {
  return request({
    url: '/uums/tree/menu/*/*/*/' + id,
    method: 'POST'
  })
}

// 组织机构Tree
export function getOrgTree(searchCon) {
  searchCon.status = '0,1'
  const search = qs.stringify(searchCon)
  return request({
    url: '/uums/SysOrgInfo/treeById',
    method: 'POST',
    data: search
  })
}

